package com.test.controller;

import com.test.service.FolderMappingService;
import com.test.vo.FolderInfoVO;
import com.ty.basic.constant.ApiPathConstant;
import com.ty.basic.response.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigInteger;

@RestController
@Api(tags = "文件夹服务")
@RequestMapping(ApiPathConstant.PRODUCT_VERSION_ONE_PATH + "folder")
public class CustomFolderController {
    @Resource
    private FolderMappingService folderMappingService;

    /**
     * 根据Oid获取文件夹信息
     *
     * @return
     */
    @GetMapping("/getFolerInfoByOid")
    @ApiOperation(value = "getFolerInfoByOid", produces = "application/json; charset=utf-8")
    public ResponseResult<FolderInfoVO> getFolerInfoByOid(HttpServletRequest request) {
        ResponseResult<FolderInfoVO> result = new ResponseResult<>();
        try {
            BigInteger folderId = new BigInteger(request.getParameter("oid"));
            folderMappingService.getFolerInfoByOid(result, folderId);
        } catch (Exception e) {
            result.setSuccess(Boolean.FALSE);
            result.setMessage(e.getMessage());
        }
        return result;
    }
}
